package io.adrainty.gbatis.transation;

import io.adrainty.gbatis.exception.CoreException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author adrainty
 * @version v1.0.0
 * @since 2024/1/14 23:20
 */

@Getter
@AllArgsConstructor
public enum TransactionType {

    JDBC("JDBC");

    private final String code;

    public static TransactionType getByCode(String code) {
        for (TransactionType type : values()) {
            if (type.getCode().equalsIgnoreCase(code)) return type;
        }
        throw new CoreException(String.format("Transaction type [%s] not match.", code));
    }

}
